#include<cstdio>
#include<cstring>
const int maxn=50001;
int t,n;
int a[maxn],c[maxn];
int low(int x)
{
	return x&(x^(x-1));
}
int sum(int x)
{
	if(x==0)return 0;
	int ans=0;
	while(x>0)
	{
		ans+=c[x];
		x-=low(x);
	}
	return ans;
}
int query(int x,int y)
{
	return sum(y)-sum(x-1);
}
void add(int i,int x)
{
	while(i<=n)
	{
		c[i]+=x;
		i+=low(i);
	}
}
int main()
{
	freopen("test.in","r",stdin);
	scanf("%d",&t);
	for(int cas=1;cas<=t;cas++)
	{
		printf("Case %d:\n",cas);
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
			scanf("%d",&a[i]);
		memset(c,0,sizeof(c));
		for(int i=1;i<=n;i++)
			for(int j=i-low(i)+1;j<=i;j++)
				c[i]+=a[j];
		char ch[10];
		while(scanf("%s",ch),strcmp(ch,"End"))
		{
			int x,y;
			scanf("%d%d",&x,&y);
			if(ch[0]=='Q')
				printf("%d\n",query(x,y));
			if(ch[0]=='A')add(x,y);
			if(ch[0]=='S')add(x,-1*y);
		}
	}
	return 0;
}
